<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header('修改-派单信息M')"/>
  <link th:href="@{/ajax/libs/bootstrap-tagsinput/tagsinput.css}" rel="stylesheet">
  <link th:href="@{/ajax/libs/jQuery-ui/jquery-ui.css}" rel="stylesheet">

</head>
<style>
  .bootstrap-tagsinput > input {
    display: none;
  }
</style>

<body style="background-color: #F4F6FA">
<div class="main-content" style="margin: 0;padding: 0">

  <form id="form-user-add" th:object="${mmailWorkForm}" class="form-horizontal" style="background-color: #F4F6FA">

    <input type="hidden" name="pkId" th:value="${mwfSendBack.pkId}">
    <div class="col-sm-12" style="display: flex">
      <div class="col-sm-12 entering-page">
        <!--    承办部门    -->
        <div class="col-sm-12 tltieBoder">
          <div class="blueBorder"></div>
          <h4 style="margin:0 0 0 10px">管理窗口-承办部门</h4>
          <h4 style="color: red;margin: 0 0 0 10px"><div id="isShow">&nbsp;已签收的不能修改承办部门</div></h4>
        </div>

        <!-- 工单编号,工单性质..-->
        <div class="col-sm-12 work-top">
          <div class="form-group col-sm-4">
            <label class="control-label formTitle">工单编号</label>
            <div class="col-sm-8">
              <input type="text" name="workFormNo" th:field="*{workFormNo}" disabled value="123"
                     class="form-control" id="workNumber"
                     placeholder="请输入名称">
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle">工单性质</label>
            <div class="col-sm-8">
              <select name="setProId" id="workCharacter" class="form-control m-b phoneCategory">
                <option value="">-请选择-</option>
                <option value="11" th:selected="*{11 == setProId}">普通工单</option>
                <option value="21" th:selected="*{21 == setProId}">督办工单</option>
                <option value="31" th:selected="*{31 == setProId}">呈批工单</option>
              </select>
              <input type="hidden" name="setProName" th:value="*{setProName}">
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle">工单主题</label>
            <div class="col-sm-8">
              <input type="text" name="fromTopic" th:field="*{fromTopic}" class="form-control"
                     id="workSubject"
                     placeholder="请输入名称">
            </div>
          </div>

          <div class="form-group col-sm-4">
            <label class="control-label formTitle is-required">承办单位</label>
            <div class="col-sm-8">
              <input type="text" name="sbdeptName" th:value="${mwfSendBack.sbdeptName}"
                     class="form-control" id="deptShort" placeholder="" autocomplete="off"
                     onclick="SelectDept()" required="required">
              <input type="hidden" name="sbdeptId" th:value="${mwfSendBack.sbdeptId}" id="noUnit">
              <div class="input-group-append " style="position: absolute;top: 10px;right: 20px;">
                <span class="glyphicon glyphicon-list-alt" style="color: #206ef7"></span>
              </div>
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle is-required">办理期限</label>
            <div class="col-sm-8">
              <input type="text" name="backLimit" th:value="${#dates.format(mwfSendBack.backLimit,'yyyy-MM-dd HH:mm:ss')}"
                     class="form-control transaction" id="transaction"
                     placeholder="请输入名称" required="required">
              <div class="input-group-append " style="position: absolute;top: 10px;right: 20px;">
                <span class="glyphicon glyphicon-calendar"></span>
              </div>
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle is-required">交办次序</label>
            <div class="col-sm-8">
              <select name="seqCode" id="workOrder" class="form-control m-b phoneCategory"
                      required="required">
                <option value="">-请选择-</option>
                <option value="10" th:selected="${'10' == mwfSendBack.seqCode}">初次交办</option>
                <option value="20" th:selected="${'20' == mwfSendBack.seqCode}">再次交办</option>
                <option value="30" th:selected="${'30' == mwfSendBack.seqCode}">三次交办</option>
              </select>
              <input type="hidden" value="初次交办" name="seqName" th:value="${mwfSendBack.seqName}">
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle is-required">办理性质</label>
            <div class="col-sm-8">
              <select name="sortCode" class="form-control m-b phoneCategory" required="required">
                <option value="">-请选择-</option>
                <option value="11" selected>主办</option>
                <option value="21"></option>
              </select>
              <input type="hidden" name="sortName" value="主办">
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle">办理方式</label>
            <div class="col-sm-8">
              <select name="dealCode" id="transactionWay" class="form-control m-b phoneCategory"
                      required="required">
                <option value="">-请选择-</option>
                <option value="11" th:selected="${'11' == mwfSendBack.dealCode}" >研究办理</option>
                <option value="21" th:selected="${'21' == mwfSendBack.dealCode}">酌情办理</option>
              </select>
              <input type="hidden" name="dealName" value="研究办理">
            </div>
          </div>
          <div class="form-group col-sm-4">
            <label class="control-label formTitle">派单时间</label>
            <div class="col-sm-8">
              <input type="text" name="sendTime"
                     th:value="${#dates.format(mwfSendBack.sendTime,'yyyy-MM-dd HH:mm:ss')}" readonly UNSELECTABLE="on"
                     class="form-control workTime" id="workTime">
            </div>
          </div>
        </div>
        <div class="col-sm-12">
          <div class="form-group col-sm-10">
            <label class="control-label formTitle is-required entering-pd" style="color: firebrick;">允许延期</label>
            <div class="col-sm-8" style="color: firebrick;">
              <label class="check-box">
                <input name="isDelay" value="0" type="radio" th:checked="'0' == ${mwfSendBack.isDelay}">允许
              </label>
              <label class="check-box">
                <input name="isDelay" value="1" type="radio" th:checked="'1' == ${mwfSendBack.isDelay}">不允许
              </label>
            </div>
          </div>
        </div>
        <!--工单备注-->
        <div class="col-sm-12">
          <div class="form-group col-sm-12">
            <label class="control-label formTitle">办理要求</label>
            <div class="col-sm-9">
                            <textarea name="sendDesc" id="sendDesc" th:text="${mwfSendBack.sendDesc}" maxlength="1000"
                                      class="form-control workRemark" rows="3"
                                      style="height: 150px"></textarea>
              <span>还可以输入<i class="workRemarkI">1000</i>个文字</span>
            </div>
          </div>
        </div>

        <div class="form-group col-sm-4">
          <label class="control-label formTitle">派单备注</label>
          <div class="col-sm-8">
            <input name="sendRemark" type="text" th:value="${mwfSendBack.sendRemark}"
                   class="form-control" id="remark" placeholder="请输入名称">
          </div>
        </div>
        <div class="form-group col-sm-4">
          <label class="control-label formTitle">派发单位</label>
          <div class="col-sm-8">
            <input name="sdeptName" th:value="${mwfSendBack.sdeptName}" type="text" class="form-control"
                   id="sdeptName" readonly
                   placeholder="请输入名称">
            <input type="hidden" name="sdeptId" id="sdeptId" th:value="${mwfSendBack.sdeptId}">
            <!--              <div class="input-group-append " style="position: absolute;top: 10px;right: 20px;">-->
            <!--                <span class="glyphicon glyphicon-list-alt" style="color: #206ef7"></span>-->
            <!--              </div>-->
          </div>
        </div>
        <div class="form-group col-sm-4">
          <label class="control-label formTitle">派发人</label>
          <div class="col-sm-8">
            <input name="suserName" th:value="${mwfSendBack.suserName}" type="text" class="form-control"
                   id="distributePerson"
                   placeholder="请输入名称">
            <input type="hidden" name="suserNo" th:value="${mwfSendBack.suserNo}">
          </div>
        </div>
        <div class="form-group col-sm-4 ui-helper-hidden">
          <label class="control-label formTitle">wfId</label>
          <div class="col-sm-8">
            <input name="wfId" th:value="${mwfSendBack.wfId}" type="text" class="form-control"
                   id="wfId">
          </div>
        </div>
        <div class="form-group col-sm-4 ui-helper-hidden">
          <label class="control-label formTitle">状态</label>
          <div class="col-sm-8">
            <input name="sendState" th:value="${mwfSendBack.sendState}" type="text" class="form-control"
                   id="sendState">
          </div>
        </div>
        <!--按钮-->
<!--        <div class="col-sm-12" style="display: flex;justify-content:center;margin:15px 0px 15px 0px">-->
<!--          <div class="form-group">-->
<!--            <div class="col-sm-3" style="display: flex;justify-content: space-evenly;">-->
<!--              <button type="button" class="btn btn-sm btn-success" onclick="submitHandler()">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;-->
<!--              <button type="button" class="btn btn-sm btn-light" onclick="closeItem()">关闭</button>-->
<!--            </div>-->
<!--          </div>-->
<!--        </div>-->

      </div>
    </div>
  </form>
</div>

<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<!--<th:block th:include="include :: select2-js" />-->
<script th:src="@{/ajax/libs/jquery-jqPaginator/jqPaginator.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-tagsinput/tagsinput.min.js}"></script>
<script th:src="@{/ajax/libs/jQuery-ui/jquery-ui.js}"></script>
<script th:src="@{/js/deptdiag.js}"></script>


<script>
  var prefix = ctx + "system/mMailWF";
  var wfId = [[${mmailWorkForm.pkId}]];
  var mailPk = [[${mmailWorkForm.originFK}]]
  var layerIndex = [[${param.layerIndex == null ? 0 :param.layerIndex}]];

  function submitHandler() {
    //if (confirm("是否保存?")){
      if ($('#sdeptId').val() != $('#deptId').val()) {
        $('#fpDirect').val(1);
        //alert($('#fpDirect').val(1));
      } else {
        $('#fpDirect').val(0)
      }
      if ($.validate.form()) {
        let data = $('#form-user-add').serializeArray();
        data.push({name: "wfId", value: wfId});
        data.push({name: "mailPk", value: mailPk});
        //alert(data.pop("wfId"));
        var config = {
          url: prefix + '/rManage/sendDeptEditJson',
          type: "post",
          dataType: "json",
          data: data,
          success: function (result) {
            $.operate.successCallback(result);
            if (layerIndex > 0) {
              var parentDialog = parent.document.getElementById('layui-layer-iframe' + layerIndex).contentWindow;
              parentDialog.$.table.refresh();
            }
          }
        };
        $.ajax(config);
      }
    //}

  }

  // function SelectBigDept() {
  //   var config = {
  //     id: 'selectDeptDialog',
  //     title: '选择派发部门<span style="color:red;margin-left: 30px;">双击选中部门</span>',
  //     width: '1050',
  //     height: '550',
  //     url: prefix + '/cmnFile/deptAllM',
  //     skin: 'layui-layer-gray',
  //     btn: ['关闭'],
  //     yes: function (index, layero) {
  //       top.layer.close(index);
  //     }
  //   };
  //   $.modal.openOptions(config);
  // }

  function SelectDept() {
    if (setReadOnly()){
      var config = {
        id: 'selectDeptDialog',
        title: '选择承办部门<span style="color:red;margin-left: 30px;">双击选中部门</span>',
        width: '1050',
        height: '550',
        skin: 'layui-layer-gray',
        url: prefix + '/cmnFile/deptAllM',
        btn: ['关闭'],
        yes: function (index, layero) {
          top.layer.close(index);
        }
      };
      $.modal.openOptions(config);
    }

  }

  function SonBackSingle(idS, nameS) {
    $('#deptShort').val(nameS);
    $('#noUnit').val(idS);
    let sendDesc = $('#sendDesc').val();
    let endIndex = sendDesc.indexOf(" 调");
    let substring = sendDesc.substring(2,endIndex);
    $('#sendDesc').val(sendDesc.replace(substring,nameS));
  }

  function SonDirectSingle(sdeptNo, sdeptName, dNo, dName) {
    $('#deptShort').val(dName);
    $('#noUnit').val(dNo);
    $('#sdeptName').val(sdeptName);
    $('#sdeptId').val(sdeptNo);
  }
  //
  // function save() {
  //   $.ajax({
  //     url: "/system/report/mail/listSubStatisticsJson",
  //     data: {},
  //     method: 'POST',
  //     dataType:'json',
  //     success: function (data) {}
  //
  //   });
  //
  // }

  $(document).ready(function () {
    setReadOnly();
  });
  function setReadOnly() {
    var sendState=document.getElementById("sendState").value;
    if(sendState==10){
      document.getElementById("isShow").hidden=true;
    }
    if(sendState!=10){
      $("#deptShort").attr("readOnly",true);
      //$("#isShow").val("已签收的不能修改承办部门");
      //document.getElementById("isShow").innerHTML("已签收的不能修改承办部门");
      return false;
    }
    return true;
  }

</script>
</body>
</html>

